package com.dc.ebond.test;

import java.lang.reflect.Method;
/**
 * 反射 测试
 * @author fengbo
 *
 */
public class FanShe {

	public static void main(String [] args) throws Exception{
		Class c=Class.forName("com.util.FileUtil"); 
		Object obj=c.newInstance(); 
		System.out.println(obj.getClass());
		Method[] ms = c.getMethods();
		for(Method m:ms){
			Class[] cl =m.getParameterTypes(); //获得参数列表
			System.out.print("方法名："+m.getName() +" 参数个数："+cl.length+"  ");
			for(Class cc:cl){
				System.out.print("\t"+cc.getName());
			}
			Class returnclass = m.getReturnType(); //返回值类型
			System.out.println("返回值类型："+returnclass.getName());
		}
		Method m = c.getMethod("createMkdir",new Class[]{Class.forName("java.lang.String")}); 
		//Method m = c.getDeclaredMethod("createMkdir",new Class[]{Class.forName("java.lang.String")});
		Object robj = m.invoke(obj,new Object[]{"D:/test"}); 
		System.out.println(robj);
	}
}
